{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3aa6814f-cfa8-4e74-9929-ffbf004d20e3",
   "metadata": {},
   "source": [
    "## Detailed Evaluation of ZapMeNot Sphere Calculations"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d2f05499-fbf1-4b98-8b4c-257768f26583",
   "metadata": {},
   "source": [
    "The objective of this notebook is to examine the details of a void sphere source calculation.\n",
    "Various results can be saved to a file for comparison against matlab or octave."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "721bc568-c92b-4e99-bb94-211152674353",
   "metadata": {},
   "outputs": [],
   "source": [
    "import math\n",
    "import sys\n",
    "from pathlib import Path\n",
    "\n",
    "import pytest\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "sys.path.insert(1,'../../../..')\n",
    "from zapmenot import model, source, shield, detector, material\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "80deeaea-dabf-4791-a56c-41acdb10a2c7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shield density =  None\n",
      "r =  0.4912570735947652\n",
      "t =  2.9126483547427737\n",
      "p =  0.0\n",
      "finished with _spherequad\n",
      "self.weights =  1.5325078872768712e-06\n",
      "r =  0.4912570735947652\n",
      "t =  2.9126483547427737\n",
      "p =  0.0\n",
      "finished with _spherequad\n",
      "self.weights =  1.5325078872768712e-06\n",
      "raw coords\n",
      "0.11149054523384626 0.0 -0.47843847115418325\n",
      "final coords\n",
      "4.111490545233846 5.0 5.521561528845817\n",
      "total distance =  20.478741962301402\n",
      "material density =  0.001205\n",
      "uncollided_flux_factor =  0.9991986630497601\n",
      "final dose is  3.8665475463219916e-07\n"
     ]
    }
   ],
   "source": [
    "# spherical source with no shielding\n",
    "# air density of 1E-10 g/cm3, similating void\n",
    "# 10 cm radius with radial and angular quadratures of 10\n",
    "# dose point is 20 cm from sphere origin\n",
    "# sphere center located at coordinates [4, 5, 6], so\n",
    "#   dose point is at [4, 5, 26] for dose point on the Z axis\n",
    "#   and [24, 5, 6] for dose point on the X axis\n",
    "# Source is 1 Bq of 1 MeV photons\n",
    "#\n",
    "# Microshield dose (unknown quadrature method) result is 3.875e-07 mR/hr.\n",
    "# Matlab dose result is 3.868745387518610e-07 mR/hr.\n",
    "myModel = model.Model()\n",
    "mySource = source.SphereSource(\"air\", sphere_radius=10,\n",
    "                               sphere_center=[4, 5, 6], density=0)\n",
    "mySource.points_per_dimension = [10, 10, 10]\n",
    "photonEnergy = 1.0  # MeV\n",
    "photonIntensity = 1  # photons/sec\n",
    "mySource.add_photon(photonEnergy, photonIntensity)\n",
    "myModel.add_source(mySource)\n",
    "myModel.add_detector(detector.Detector(4, 5, 26))\n",
    "result = myModel.calculate_exposure()\n",
    "print(\"final dose is \",result)\n",
    "# assert result == pytest.approx(3.868745387518610e-07)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47389314-8aa4-4b33-9cb3-35877dad5361",
   "metadata": {},
   "outputs": [],
   "source": [
    "myModel.long_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c9c5fc6f-4815-42c5-a946-ae47657c53d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "myModel.collided_point_exposure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fadcd4d2-932e-4f47-b76d-88ab82ed17f4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
